# -*- coding: utf-8 -*-

# The Main App for MQBook.
#
# Created: Mon Dec 20 20:56:08 2010
#      By: leaboy.w
#   Email: leaboy.w@gmail.com
#
# GNU Free Documentation License 1.3

from PyQt4 import QtCore, QtGui

from MQBookUI import Ui_MQBook

class MQBookUI(QtGui.QMainWindow):
    def __init__(self, parent=None):
        super(MQBookUI, self).__init__(parent)

        self.ui = Ui_MQBook()
        self.ui.setupUi(self)

        self.ConnectEvent()


    def ConnectEvent (self):
        self.ui.Action_File_Add.setShortcut('Ctrl+N')
        self.ui.Action_File_Add.triggered.connect(self.NewAdd)
        self.ui.Action_File_Print.setShortcut('Ctrl+P')
        self.ui.Action_File_Print.triggered.connect(self.print_)
        self.ui.Action_File_Quit.setShortcut('Ctrl+Q')
        self.ui.Action_File_Quit.triggered.connect(QtGui.qApp.closeAllWindows)


    def NewAdd (self):
        pass


    def print_ (self):
        self.printer = QtGui.QPrinter()
        dialog = QtGui.QPrintDialog(self.printer,self)
        if dialog.exec_():
            painter = QtGui.QPainter(self.printer)
            #rect = painter.viewport()
            #size = self.image.pixmap().size()
            #size.scale(rect.size(),QtCore.Qt.KeepAspectRatio)
            #painter.setViewport(rect.x(),rect.y(),size.width(),size.height())
            #painter.setWindow(self.image.pixmap().rect())
            #painter.drawPixmap(0,0,self.image.pixmap())




if __name__ == "__main__":
    import sys

    app = QtGui.QApplication(sys.argv)
    MainApp = MQBookUI()
    MainApp.show()
    sys.exit(app.exec_())

